package com.mostromas.ess.project.controller;

import com.alibaba.fastjson.JSONArray;
import com.mostromas.ess.util.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "拼多多官方采集管理接口", description = "提供官方API的采集接口")
@RestController
@RequestMapping("/sdk")
public class PDDServerProductController {
    private static String clientId = "c42e057321fc49e1b4a3dbf9cfb4f7fd";
    private static String clientSecret = "170951f04baad07583998dd67f50e0348b65ae21";

    @ApiOperation("查询商品标准类目接口")
    @ApiImplicitParam(name = "parentId",value = "0",required = true)
    @GetMapping("/get_cats/{parentId}")
    public Result getGoodsCats(@PathVariable("parentId") String parentId) throws Exception {
//        PopClient client = new PopHttpClient(clientId, clientSecret);
//
//        PddGoodsCatsGetRequest request = new PddGoodsCatsGetRequest();
//        request.setParentCatId(Long.parseLong(parentId));
//        PddGoodsCatsGetResponse response = client.syncInvoke(request);

        return Result.ok(null);
    }
    @ApiOperation("查询商品标签类目ID接口")
    @ApiImplicitParam(name = "parentId",value = "0",required = true)
    @GetMapping("/get_opts/{parentId}")
    public Result getGoodsOpts(@PathVariable("parentId") String parentId) throws Exception {
//        PopClient client = new PopHttpClient(clientId, clientSecret);
//
//        PddGoodsOptGetRequest request = new PddGoodsOptGetRequest();
//        request.setParentOptId(Integer.parseInt(parentId));
//        PddGoodsOptGetResponse response = client.syncInvoke(request);

        return Result.ok(null);
    }
    @ApiOperation("商品搜索接口")
    @ApiImplicitParam(name = "cat_id",value = "0",required = true)
    @GetMapping("/get_goods/{cat_id}/{keyword}")
    public Result getGoodsSearch(@PathVariable("cat_id") String catId,@PathVariable("keyword") String keyword) throws Exception {
//        PopClient client = new PopHttpClient(clientId, clientSecret);
//        PddDdkGoodsSearchRequest request = new PddDdkGoodsSearchRequest();
//        request.setPid("8456749_225963777");
//        request.setCatId(Long.parseLong(catId));
//        request.setKeyword(keyword);
//        request.setPage(1);
//        request.setPageSize(100);
//        PddDdkGoodsSearchResponse response = client.syncInvoke(request);
        return Result.ok(null);
    }
    @ApiOperation("商品详情查询接口")
    @ApiImplicitParam(name = "goodsSign",value = "0",required = true)
    @GetMapping("/get_goods_detail/{goodsSign}")
    public Result getGoodsDetail(@PathVariable("goodsSign") String goodsSign) throws Exception {
//        PopClient client = new PopHttpClient(clientId, clientSecret);
//
//
//        PddDdkGoodsDetailRequest request = new PddDdkGoodsDetailRequest();
//        request.setGoodsSign(goodsSign);
//        request.setNeedSkuInfo(false);
//        request.setPid("8456749_225963777");
//        PddDdkGoodsDetailResponse response = client.syncInvoke(request);
//        System.out.println(JsonUtil.transferToJson(response));
        return Result.ok(null);
    }
}
